package com.fjnldx.mes.domain.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import org.thymeleaf.util.StringUtils;

import java.time.LocalDate;

@Data
@TableName(value = "mes_newscjh")
@Accessors(chain = true)
public class ProductionPlan {
    @TableId(type = IdType.AUTO)
    private Integer id;
    private String scjhbh;
    private String devSn;
    private String pz;
    private String zs;
    private String gongxu;
    private String dcg;
    private String gh;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate time;
    private String ds;
    private String dl;
    private String xiaolv;
    private String cs;
    private String zl;
    private String tc;
    private String jisuan;

    public String saveCheck() {
        StringBuilder sb = new StringBuilder();
        if (StringUtils.isEmpty(this.getDevSn())) {
            sb.append("devSn不能为空");
        }
        if (StringUtils.isEmpty(this.getPz())) {
            sb.append("pz不能为空");
        }
        if (StringUtils.isEmpty(this.getPz())) {
            sb.append("工序不能为空");
        }
        return sb.toString();
    }

    public String updateCheck() {
        StringBuilder sb = new StringBuilder();
        if (null == this.getId()) {
            sb.append("id不能为空");
        }
        if (StringUtils.isEmpty(this.getDevSn())) {
            sb.append("devSn不能为空");
        }
        if (StringUtils.isEmpty(this.getPz())) {
            sb.append("pz不能为空");
        }
        if (StringUtils.isEmpty(this.getPz())) {
            sb.append("工序不能为空");
        }
        return sb.toString();
    }
}
